package com.lyc.product.bean;

import java.util.List;

/**
 * 分页类(泛型类)
 */
public class Page<T>  {
  //总页数
  private int TotalPageCount;
  //每页显示的记录数
  private  int PageRecordCount=6;
  //总记录数
  private  int TotalRecordCount;
  // 每页显示的内容
  private List<T> PageCotent;
  //当前指定的页数
  private int CurrentPageCount;

    public Page(int currentPageCount) {
       this.CurrentPageCount = currentPageCount;
    }

    /**
     * 判断总页数 (总记录数/每页显示的记录数）
     * @return
     */
    public int getTotalPageCount() {

        this.TotalPageCount=this.TotalRecordCount/this.PageRecordCount;
        if (this.TotalRecordCount%this.PageRecordCount!=0){
            this.TotalPageCount++;
        }
        return TotalPageCount;
    }


    public void setTotalPageCount(int TotalPageCount) {

        this.TotalPageCount = TotalPageCount;
    }

    public int getPageRecordCount() {
        return PageRecordCount;
    }

    public void setPageRecordCount(int pageRecordCount) {
        this.PageRecordCount = pageRecordCount;
    }

    public int getTotalRecordCount() {
        return TotalRecordCount;
    }

    public void setTotalRecordCount(int totalPageCount) {
        this.TotalRecordCount = totalPageCount;
    }

    public List<T> getPageCotent() {
        return PageCotent;
    }

    public void setPageCotent(List<T> pageCotent) {
        this.PageCotent = pageCotent;
    }

    public int getCurrentPageCount() {
        return CurrentPageCount;
    }

    /**
     * 判断输入的当前指定页数是否合法
     * 如果currentPageCount<1，则显示第一页，如果大于最后一页，则显示最后一页
     * @param currentPageCount
     */
    public void setCurrentPageCount(int currentPageCount) {
        if (currentPageCount>getTotalPageCount()){
            currentPageCount=getTotalPageCount() ;
        }
        if (currentPageCount<1){
            currentPageCount=1;
        }
       this.CurrentPageCount = currentPageCount;
    }
}
